<?php
// +----------------------------------------------------------------------
// | XiaMiCMF - 代码如诗
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://shujuwajue.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 小虾米 <509129@qq.com>
// +----------------------------------------------------------------------
namespace Common\Model;

class NavModel extends CommonModel {

    protected $orderBy = array('sort' => 'ASC');

    //自动验证
    protected $_validate = array(
        //array(验证字段,验证规则,错误提示,验证条件,附加规则,验证时间)
        array('nav_name', 'require', '导航菜单名称不能为空', self::MUST_VALIDATE, 'regex', self::MODEL_BOTH),
    );

    public function getNavsByCateId($cate_id) {
        $rows = array();
        $data = $this->where(array('cate_id' => $cate_id))->order($this->orderBy)->select();
        if (!empty($data)) {
            foreach ($data as $row) {
                $rows[$row['nav_id']] = $row;
            }
        }
        return $rows;
    }


}